Merge status-key
authorjustbur <justin@burkett.cc>
Sat, 11 Jul 2015 16:49:05 +0000 (12:49 -0400)
committerjustbur <justin@burkett.cc>
Sat, 11 Jul 2015 16:49:05 +0000 (12:49 -0400)
1  2 
which-key.el

diff --cc which-key.el
index b03140a9ba13ea6673dd4ff2938881bb1a9a3922,9b150aca206cbb55e6032856b97e86f69ab3ba9c..b71498c3b0401896a1ba24ecbec46b6825407eef
@@@ -691,32 -713,42 +713,42 @@@ the maximum number of lines availabel i
           (prefix-width (if (eq which-key-show-prefix 'left) prefix-len 0))
           (avl-width (when (cdr max-dims) (- (cdr max-dims) prefix-width)))
           (keys-rem formatted-keys)
-          (max-iter (+ 1 n-keys))
-          (iter-n 0)
-          keys-per-page pages first-page first-page-str page-res)
-     (while (and (<= iter-n max-iter) keys-rem)
-       (setq iter-n (1+ iter-n)
-             page-res (which-key/create-page vertical max-height avl-width prefix-width keys-rem)
 -         (max-pages (+ 1 (length keys-rem)))
++         (max-pages (+ 1 (length formatted-keys)))
+          (page-n 0)
+          keys-per-page pages first-page first-page-str page-res no-room
+          max-pages-reached)
+     (while (and keys-rem (not max-pages-reached) (not no-room))
+       (setq page-n (1+ page-n)
+             page-res (which-key/create-page keys-rem
+                                             max-lines avl-width prefix-width
+                                             vertical which-key-show-page-number page-n)
              pages (push page-res pages)
              keys-per-page (push (if (nth 4 page-res) (nth 4 page-res) 0) keys-per-page)
-             keys-rem (nth 3 page-res)))
+             keys-rem (nth 3 page-res)
+             no-room (<= (car keys-per-page) 0)
+             max-pages-reached (>= page-n max-pages)))
      ;; not doing anything with other pages for now
      (setq keys-per-page (reverse keys-per-page)
            pages (reverse pages)
            first-page (car pages)
            first-page-str (concat prefix-string (car first-page)))
-     (if (or (<= n-keys 0) (<= (car keys-per-page) 0))
-         (progn
-           (message "which-key can't show keys: The settings and/or frame size are too restrictive.")
-           (cons 0 0))
-       ;; (when (> (length pages) 1) (setq first-page (concat first-page "...")))
-       (if (eq which-key-popup-type 'minibuffer)
-           (let (message-log-max) (message "%s" first-page-str))
-         (with-current-buffer which-key--buffer
-           (erase-buffer)
-           (insert first-page-str)
-           (goto-char (point-min))))
-       (cons (nth 1 first-page) (nth 2 first-page)))))
+     (cond (no-room
+            (message "which-key can't show keys: The settings and/or frame size are too restrictive.")
+            (cons 0 0))
+           (max-pages-reached
+            (error "error: which-key reached the maximum number of pages")
+            (cons 0 0))
+           ((<= (length formatted-keys) 0)
 -           (error "error: which-key: no keys to display")
++           (message "which-key: no keys to display")
+            (cons 0 0))
+           (t
+            (if (eq which-key-popup-type 'minibuffer)
+                (let (message-log-max) (message "%s" first-page-str))
+              (with-current-buffer which-key--buffer
+                (erase-buffer)
+                (insert first-page-str)
+                (goto-char (point-min))))
+            (cons (nth 1 first-page) (nth 2 first-page))))))
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; Update